﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Entity;

namespace DataAccess
{
    public class GroupUserDA
    {
        //lay ten group theo tai khoan
        public string getGroupNameByAccount(Account acc)
        {
            string nameGroup = null;
            using (SqlConnection conn = Connect.getConnection())
            {
                try
                {
                    conn.Open();
                    //lay chuc vu cua tai khoan dang nhap
                    SqlCommand cmd = new SqlCommand("getGroupNameByAccount", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@userID", acc.accountID));
                    SqlDataReader drGroupName = cmd.ExecuteReader();
                    while (drGroupName.Read())
                    {
                        nameGroup = drGroupName["GroupName"].ToString();
                    }
                    conn.Close();
                    return nameGroup;
                }
                catch (Exception)
                {
                    conn.Close();
                    return null;
                }
            }
        }
    }
}
